home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Just Call Me Internet
/
Just Call Me Internet.iso
/
archives
/
com
/
internet
/
stik
/
gls002b5.zoo
/
gsdriver.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-09-13
|
2KB
|
125 lines
#include <osbind.h>
#include <mintbind.h>
#include <basepage.h>
#include <ctype.h>
#include <minimal.h>
#include <string.h>
#include "cookie.h"
#include "patchlev.h"
#include "global.h"
#include "pipe.h"
long _stksize = 65536L;
int cjar_size = 0;
COOKIE *new_cjar = 0;
int ncookies = 0;
int mint_present = 0;
int stik_present = 0;
int pipe_fd = 0;
#ifdef __MINT__
/* We define these here to keep main.o from being pulled out of libc.a */
int errno;
int __mint;
#endif
int check_cookies(void)
{
register COOKIE *cjar = *CJAR, *C;
if (!cjar)
return 0;
for (C = cjar; C->tag != 0; C++) {
if (C->tag == COOKIE_MiNT)
mint_present = 1;
if (C->tag == COOKIE_STiK)
stik_present = 1;
}
cjar_size = C->value;
ncookies = C - cjar;
return 0;
}
int install_same_jar(void)
{
register COOKIE *C = *CJAR + ncookies;
C->tag = COOKIE_STiK;
C->value = (long)&driver;
C[1].tag = 0;
C[1].value = cjar_size;
return 0;
}
int install_new_jar(void)
{
register COOKIE *oldC = *CJAR, *newC = new_cjar;
*CJAR = newC;
while (oldC->tag != 0)
*newC++ = *oldC++;
newC->tag = COOKIE_STiK;
newC->value = (long)&driver;
newC[1].tag = 0;
newC[1].value = cjar_size + 8;
return 0;
}
int install_cookie(void)
{
if (ncookies < cjar_size - 1)
return Supexec(install_same_jar);
else {
if (!(new_cjar = (COOKIE *)Mxalloc((cjar_size + 8) * sizeof(COOKIE), 3))) {
Cconws("Unable to install STiK cookie\r\n");
return -1;
}
return Supexec(install_new_jar);
}
}
/* cleanup() -- free everything we might have alloced, and destroy all
semaphores we might have created. */
static void cleanup(void)
{
/* As it turns out, we have nothing to clean up here. */
}
int main()
{
Cconws("\r\nGlueSTiK\277 STiK emulator for MiNTnet\r\n"
"Application interface driver\r\n"
"Version " GS_VERSION "\r\n"
"\275 1996 Scott Bigham\r\n");
Supexec(check_cookies);
if (!mint_present) {
Cconws("MiNT not present --- not installing\r\n");
return -1;
}
if (stik_present) {
Cconws("STiK already present --- not installing\r\n");
return 0;
}
if (!init_stubs()) {
cleanup();
return -1;
}
if (install_cookie() < 0) {
cleanup();
return -1;
}
Cconws("\r\n");
Ptermres(1024L + _base->p_tlen + _base->p_dlen + _base->p_blen, 0);
return -1;
}